import * as Api from '@/api/processClient/processClient';
// 导出适配器
export class Adapter {
  #data: any;
  constructor (data: any) {
    this.#data = data;
  }
  adapterData = () => {
    
  }
  getData = () => {
    // return this.series.getCurrent();
  }
}
// 序列类
export class Series {
  readonly taskId: number;
  readonly userId: number;
  seriesList: string[];
  sarIdList: number[];
  constructor(taskId: number, userId: number) {
    this.taskId = taskId;
    this.userId = userId;
    this.seriesList = [];
    this.sarIdList = [];
  }
  // 调用获取审核序列接口
  getSeries = async () => {
    const seriesParams = {
      taskId: this.taskId,
      userId: this.userId
    }
    const seriesRes = await Api.getSeries(seriesParams);
    // 请求结果
    this.seriesList = seriesRes.data.seriesList.map(item => item.series);
    this.sarIdList = seriesRes.data.sarIdList;
  }
  getCurrent = () => {

    return new CurrentSeries(this.seriesList).getIncreaseCurrent();
  }
}
// 获取当前序列
export class CurrentSeries {
  seriesList: string[];
  index: number;
  constructor(list: string[]) {
    this.seriesList = list;
    this.index = -1;
  }
  getIncreaseCurrent() {
    if (this.hasNext()) {
      return this.seriesList[++this.index];
    }
    return null;
  }
  getDecreaseCurrent() {
    if (this.hasPrev()) {
      return this.seriesList[--this.index];
    }
    return null;
  }
  hasNext() {
    if (this.index >= this.seriesList.length) {
      return false;
    }
    return true;
  }
  hasPrev() {
    if (this.index <= 0) {
      return false;
    }
    return true;
  }
}